How to count occurrences of a character in in